import os
import sys
import django
import datetime


# 环境变量

sys.path.append(r'C:\Users\82628\Desktop\MIS\MIS')

os.chdir(r'C:\Users\82628\Desktop\MIS\MIS')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MIS.settings")
django.setup()

# 这一行的位置不能变，千万别把这个应用扔到开头去
from production_ms.models import *
from django.db.models import *


from django.db import connection

# values_list('register_date', 'name')
# .latest('register_date')
# .earliest('register_date')
# v = Test.objects.all().values()
# v = models.Test.objects.get('register_date')
# v = Test.objects.alias(sum('test_number')).values_list().earliest('register_date')[0]
#v = DownParse.objects.filter(date__range=('2021-07-01', '2021-07-10')).values_list('unit').annotate(Sum('machine'),Sum('electric'),Sum('self'),Sum('change'),Sum('work'),Sum('day_product'))

v = Down1.objects.values_list('date').filter(date__range=('2021-10-10', '2021-10-20')).distinct()
print(v)
# print([list(item)[0] for item in v])
# print(connection.queries[0]['sql'])
# for i in v:
#     for j in i:
#         print(j)
#     print('\n')
# print(v[0].isoformat())
# for i in v:
#     print(i)
